package rosterhandler

import (
	"github.com/gin-gonic/gin"
	"yundian/internel/app/dao"
	"yundian/internel/app/models/rostersetting"
	"yundian/internel/pkg/dingo"
	. "yundian/internel/pkg/dingo/result"
)

func HandlerGetRoster(c *gin.Context) {
	param := &struct {
		Type int `json:"type" form:"type"`
	}{}

	dingo.ErrorIf(c.Bind(param)).Unwrap()
	data := dao.NewRosterSettingDao().GetRosterList(param.Type)
	Response(c)("", CodeSuccess, ResponseList{
		Data: data.Unwrap(),
	})(OK)
}

func HandlerUpdateRoster(c *gin.Context) {
	param := &rostersetting.RosterSetting{}
	dingo.ErrorIf(c.Bind(&param)).Unwrap()
	Response(c)("", CodeUpdateSuccess, dao.NewRosterSettingDao().UpdateRoster(param))(OK)
}
